/* selection.c */

#include <stdlib.h>

#include "selection.h"

typedef struct {
  int type;
  int point;
  int segment;
} PATH_SELECTION;

static PATH_SELECTION cur_selection;

void sel_clear(void)
{
  cur_selection.type = -1;
}

int sel_get_point(int *point)
{
  if (cur_selection.type != 0) {
    *point = -1;
    return 0;
  }

  *point = cur_selection.point;
  return 1;
}

void sel_set_point(int point)
{
  cur_selection.type = 0;
  cur_selection.point = point;
}

int sel_get_segment(int *point, int *segment)
{
  if (cur_selection.type != 1) {
    *point = *segment = -1;
    return 0;
  }

  *point = cur_selection.point;
  *segment = cur_selection.segment;
  return 1;
}

void sel_set_segment(int point, int segment)
{
  cur_selection.type = 1;
  cur_selection.point = point;
  cur_selection.segment = segment;
}
